package day05;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @author zouran
 * createDate：2024/7/3  16:04
 */
public class UploadTCPClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10000);
        InputStream file = new FileInputStream("D:\\Users\\13055\\Desktop\\patent-.drawio.png");
        OutputStream out = socket.getOutputStream();
        System.out.println("显示到服务器端，开始文件上传！");
        byte[] bytes = new byte[1024];
        int len;
        while ((len = file.read(bytes)) != -1) {
            out.write(bytes, 0, len);
        }
        file.close();
        socket.shutdownOutput();
        InputStream input = socket.getInputStream();
        System.out.println(new String(input.readAllBytes()));
        input.close();
        out.close();
        socket.close();
    }
}
